package net.cyan.proteus;

import java.io.*;

/**
 * 
 * @author camel
 * @date 2008-3-12
 */
public class BaseTemplateWriter extends AbstractTemplateWriter
{
    private Writer writer;

    public BaseTemplateWriter(Writer writer)
    {
        this.writer = writer;
    }

    public BaseTemplateWriter(OutputStream out)
    {
        this.writer = new BufferedWriter(new OutputStreamWriter(out));
    }

    public BaseTemplateWriter(OutputStream out, String charset) throws UnsupportedEncodingException
    {
        this.writer = new BufferedWriter(new OutputStreamWriter(out, charset));
    }

    public void write(String s) throws IOException
    {
        if (s == null)
            s = "null";
        writer.write(s);
        writer.flush();
    }
}
